﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Unity;
using RentAWorker.Management.Infrastructure.CommunicationServices;
using RentsList;
using RentReturn;

namespace RentManagement
{
    public class RentManagementModule : IModule
    {
        private IUnityContainer Container { get; set; }

        public RentManagementModule(IUnityContainer container)
        {
            this.Container = container;
        }

        public void Initialize()
        {
            RegisterTypes();

            this.Container.Resolve<ModuleController>().Run();
        }

        private void RegisterTypes()
        {
            this.Container.RegisterType<IRentManagementCommService, ModuleController>(
                new ContainerControlledLifetimeManager());

            this.Container.RegisterType<IRentsListPresentationModel, RentsListPresentationModel>();
            this.Container.RegisterType<IRentsListView, RentsListView>();

            this.Container.RegisterType<IRentReturnPresentationModel, RentReturnPresentationModel>();
            this.Container.RegisterType<IRentReturnView, RentReturnView>();
        }
    }
}
